const mongoose = require('mongoose');

const adminsSchema = new mongoose.Schema({
        account: String,
        password: {
            type: String,
            set: function(val) {
                return require('bcrypt').hashSync(val, 10)
            }
        },
        power: Number,
        state: Number,
    }, { versionKey: false }
    // {
    //     toJSON: { virtual: true }
    // }
);

// adminsSchema.virtual('logs', {
//     ref: 'logsModel',
//     localField: '_id',
//     foreignField: 'adminsId',
//     justOne: false
// })

const adminsModel = mongoose.model('adminsModel', adminsSchema, 'admins');

module.exports.adminsModel = adminsModel;